<?php
//error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require('./roots.php');
require($root_path.'include/inc_environment_global.php');

/**
* CARE2X Integrated Hospital Information System beta 2.0.1 - 2004-07-04
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/

define('LANG_FILE','interconsulta.php');
define('NO_2LEVEL_CHK',1);
require_once($root_path.'include/inc_front_chain_lang.php');

$thisfile=basename(__FILE__);
$breakfile='interconsulta.php';
$action='interconsulta-save.php'.URL_APPEND.'&update=1&id='.$id.'&res=1';

require_once($root_path.'include/care_api_classes/class_core.php');
$core=new Core;

require_once($root_path.'include/care_api_classes/class_interconsulta.php');
$interconsulta = new Interconsulta;
$user = $interconsulta->preloadUserInfo($_SESSION['sess_login_userid']);
$temp = $interconsulta->getAllInfoObject($id);
$filesR = $interconsulta->seleccionarNombreAdjuntos($id, "_resp");

$archivosR="";

if (count($filesR))
{
    foreach($filesR as $file){
            $name = $file['name'];
            $option="menubar=no,width=600,height=6000,resizable=yes,scrollbars=yes";

            if (strlen($name))
            {
                    $url="../../modules/interconsulta/include/showImage.php?id=$id&name=$name&resp=_resp";
                    $archivosR .= "<a href=\"javascript: window.open('$url','wblabel','$option'); exit;\">$name</a> ";

            }
    }
}
if($archivosR=='') $archivosR=$LDNinguno;

extract($temp->FetchRow());

$sTemp='';
?>
<style type="text/css">
.reg_item{
        background-color: #eeeeee;
        padding: 2px 6px 2px 6px;
        border-bottom: 1px solid green;
}
.reg_input{
        background-color: #ffffee;
        padding-left: 6px;
}

</style>

<script>
        function popWin()
        {
            urlholder="./interconsulta-adjuntar.php<?php echo URL_REDIRECT_APPEND;?>";
            DSWIN<?php echo $sid ?>=window.open(urlholder,"wblabel<?php echo $sid ?>","menubar=no,width=400,height=150,resizable=yes,scrollbars=yes");
         }

        function chkform(d) {
                        if (d.respuesta.value==""){//
                                alert("<?php echo $LDRespErr; ?>");
                                d.respuesta.focus();
                                return false;
                        }else if(d.diagnostico.value==""){//
                                alert("<?php echo $LDDiagnosErr; ?>");
                                d.diagnostico.focus();
                                return false;
                        }
                        else if(d.tratamiento.value==""){//
                                alert("<?php echo $LDTrataErr; ?>");
                                d.tratamiento.focus();
                                return false;
                        }
                }
</script>

<form method="post" action="<?php echo $action ?>" name="regform" ENCTYPE="multipart/form-data" onSubmit="return chkform(this)">
<blockquote>
<h3><?php echo $LDRespInter ?></h3>
<input type="hidden" name="respuesta" value="1">
<table cellSpacing=0  width=600 cellpadding="0">
<tbody>

<tr>
        <td class="reg_item">
                <?php echo $LDInterconsultado; ?>
        </td>
        <td class="reg_input">
                <input name="interconsultado" type="text" size="28" value="<?php echo $user['name']; ?>" readonly>
        </td>
</tr>
<tr>
        <td class="reg_item">
                <?php echo $LDResponse; ?>
        </td>
        <td class="reg_input">
                <textarea name="respuesta" cols="35" rows="5"><?= $respuesta;?></textarea>
        </td>
</tr>
<tr>
        <td class="reg_item">
                <?php echo $LDDiagnosis; ?>
        </td>
        <td class="reg_input">
                <textarea name="diagnostico" cols="35" rows="5"><?= $diagnostico;?></textarea>
        </td>
</tr>
<tr>
        <td class="reg_item">
                <?php echo $LDTreatment; ?>
        </td>
        <td class="reg_input">
                <textarea name="tratamiento" cols="35" rows="5"><?= $tratamiento;?></textarea>
        </td>
</tr>
<tr>
        <td class="reg_item">
                <?php echo $LDObs; ?>
        </td>
        <td class="reg_input">
                <textarea name="observaciones" cols="35" rows="5"><?= $observaciones?></textarea>
        </td>
</tr>
<tr>
        <td class="reg_item">
		<?php echo $LDArchivoAdjunto; ?>
        </td>
        <td>
            <?= $archivosR ?>
        </td>
</tr>
<tr>
        <td class="reg_item">
		<?php echo $LDAjuntar; ?>
        </td>
        <td class="reg_input">
                <input name="listaArchivos" type="text" size="35" readonly><a href="javascript:popWin()"> <?php echo "<img ".createComIcon($root_path,'b-write_addr.gif','0').">" ?></a>
        </td>
</tr>
<tr>
        <td class="reg_item">
		<?php echo $LDComment; ?>
        </td>
        <td class="reg_input">
            <textarea name="comentarios_resp" cols="35" rows="5"><?= $comentarios_resp?></textarea>
        </td>
</tr>
</tbody>
</table>
</blockquote>
<p>
<?php

echo "<input type=\"image\"" . createLDImgSrc($root_path,'savedisc.gif','0'). " alt=\"$LDSaveData\" align=\"absmiddle\">";
echo "<a href=\"javascript:document.regform.reset()\"><img ". createLDImgSrc($root_path,'reset.gif','0') . "alt=\"$LDResetdata\"  align=\"absmiddle\"></a>";

?>
</p>
</form>
